using UnityEngine;
using UnityEngine.Rendering.Universal;

public class NPRRenderFeature : ScriptableRendererFeature
{
    [SerializeField] private Shader _shader;

    NPRBloomPass _renderPass;

    public override void Create()
    {
        _shader = Shader.Find("Post-Processing/NPR Postprocess");
        if (!_shader) return;

        _renderPass = new NPRBloomPass(_shader);
        _renderPass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
    }

    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (_shader && renderingData.cameraData.postProcessEnabled && renderingData.cameraData.renderType == CameraRenderType.Base)
            renderer.EnqueuePass(_renderPass);
    }

    protected override void Dispose(bool disposing)
    {
        _renderPass?.OnDispose();
        _renderPass = null;
        _shader = null;
    }
}